package src.lab03.Test03;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;

/**
 * Created by 12442 on 2017/11/16.
 */
public class Test {
    public static void main(String[] args) throws FileNotFoundException {
        String path="D:\\test.txt";
        //字节流写文件
        try{
            FileOutputStream fileOutputStream= new FileOutputStream(path);
            //10101011字节
            fileOutputStream.write("北京欢迎你！".getBytes());
        } catch (FileNotFoundException e){
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }finally {
            try{
                FileInputStream fileInputStream=new FileInputStream(path);
                //10101010->int
                int tmp;
               while ((tmp=fileInputStream.read())!=-1){
                   System.out.println((char) tmp);
               }
            } catch (FileNotFoundException e){
                e.printStackTrace();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}
